/**
 * ConvertCurrency - Defines the class for currency conversion.
 * 
 * CS575 Software Design
 * Group 6
 * Group Members: Anthony Davidson, Kendra Scheesley, Lyndsey Whitman, Stephen Zakrewsky
 * Date: June 2, 2012
 * Main Author(s): Lyndsey Whitman
 */

package edu.drexel.cs575.a3;

import java.util.HashMap;
import java.util.Map;

import edu.drexel.cs575.a3.location.LocaleEnum;

public abstract class ConvertCurrency
{

	/*
	 * This is a static map for now. In the future it can be populated by the
	 * system, or read from a configuration file.
	 */
	private static Map<LocaleEnum, ConvertCurrency>	currencyToStrategyMap	= new HashMap<LocaleEnum, ConvertCurrency>();
	static
	{
		currencyToStrategyMap.put(LocaleEnum.US, new USDollarCurrency());
		currencyToStrategyMap.put(LocaleEnum.CANADA, new CanadianDollarCurrency());
		currencyToStrategyMap.put(LocaleEnum.MEXICO, new PesoCurrency());
		currencyToStrategyMap.put(LocaleEnum.MOON, new LunaCurrency());
	}

	public abstract double convertCurrency(double currentPrice);

	public static ConvertCurrency getInstanceForLocale(LocaleEnum locale)
	{
		ConvertCurrency curencyConverter = currencyToStrategyMap.get(locale);
		
		if (curencyConverter == null)
		{
			throw new IllegalStateException("Currency Converter is not Configured");
		}
		return curencyConverter;
	}

	
}
